package utils;

import java.sql.*;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by David on 2017/7/30 030.
 */
public class MysqlUtils {
    private final String url = "jdbc:mysql://localhost/diandi?characterEncoding=utf8&useSSL=false";
    private final String name = "com.mysql.jdbc.Driver";
    private final String user = "root";
    private final String password = "cc000111";

    private Connection conn = null;

    public MysqlUtils(){
        try{
            connect();
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    private void connect() throws Exception{

        Class.forName(name); //指定连接类型
        conn = DriverManager.getConnection(url, user, password); //获取连接
//        System.out.println("connected");
    }

    public ResultSet querySql(String sql){
        try{
            if (conn == null) connect();
            //conn.close();
            return conn.prepareStatement(sql).executeQuery();
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    // 根据用户email查询到他的密码，如果为空则用户不存在
    public String getPassword(String email){
        try {
            String sql = "select password from user where email='" + email +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret.getString(1);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取邮件验证码
    public ResultSet getEmailVerify(String email){
        try {
            String sql = "select email_vcode,email_vtime from user where email='" + email +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 查询用户的信息，包含个人敏感信息
    public ResultSet getUserInfo(String email){
        try {
            String sql = "select nickname,signature,area,sex,birthday,head_image," +
                    "count(case when from_id=user.id then from_id end) as follow_num," +
                    "count(case when to_id=user.id then to_id end) as fans_num,email_active " +
                    "from user left join follow on user.id=from_id or user.id=to_id " +
                    "where email='" + email +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 根据用户id查询信息，仅包含用户公开的信息
    public ResultSet getUserIdInfo(String userId){
        try {
            String sql = "select nickname,signature,area,sex,birthday,head_image,count(case when from_id=user.id then from_id end) as follow_num,count(case when to_id=user.id then to_id end) as fans_num,user.id from user left join follow on user.id=from_id or user.id=to_id where user.id='" + userId +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取用户id
    public String getUserId(String email){
        try {
            String sql = "select id from user where email='" + email +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret.getString(1);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取用户与某个id的用户的关系，陌生、关注、被关注、互粉
    public String getFollowStatus(String email, String toId){
        try {
            String myId = getUserId(email);
//            System.out.println("logined_id: "+myId+", to_id: "+toId);
            if (myId.equals(toId)) {
//                System.out.println(myId + "==" + toId);
                return "self";
            }
            String sql = "SELECT count(case when from_id='"+toId+"' then from_id end) as fans, count(case when to_id='"+toId+"' then from_id end) as followed from follow where from_id='" + myId +  "' or to_id='" + myId +  "'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                String fans = ret.getString(1);
                String followed = ret.getString(2);

                if (fans.equals("0")){
                    if (followed.equals("0")) return "stranger";
                    else return "followed";
                }else {
                    if (followed.equals("0")) return "fans";
                    else return "friend";
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "stranger";
    }

    // 检查经过mysql的password函数加密后密码是否一致
    public boolean checkPassword(String inputPassword, String savedPassword){
        try{
            ResultSet ret = querySql("select password('" + inputPassword + "')");
            if (ret.next()){
                if (ret.getString(1).equals(savedPassword)){
                    return true;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 用户注册
    public boolean userRegister(String email,String nickname, String psw, String vcode){
        try{
            String currentTime = String.valueOf(System.currentTimeMillis());
            String sql = "insert into user (email,nickname,password,reg_time,email_vcode,email_vtime) " +
                        "values ('" + email + "','" + nickname + "',password('" + psw + "'),'" + currentTime + "','"+vcode+"','"+currentTime+"')";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            System.out.println(rowEffect);
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 更新邮箱验证码
    public boolean updateEmailVcode(String email, String vcode){
        try{
            String sql = "update user set email_vcode='"+vcode+"',email_vtime='"+System.currentTimeMillis()+"' where email='"+email+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            System.out.println(rowEffect);
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 验证邮箱
    public boolean comfirmEmail(String email){
        try{
            String sql = "update user set email_active='1' where email='"+email+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            System.out.println(rowEffect);
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 修改用户信息
    public boolean userSetInfo(String email, HashMap<String, String> data){
        try {
            StringBuilder settingQuery = new StringBuilder();
            for (Map.Entry<String, String> entry : data.entrySet()) {
                String key = entry.getKey();
                String val = entry.getValue();
                String thisQuery;
                if (key.equals("birthday") && (val.equals("") || val.isEmpty())){
                    thisQuery = key + "=NULL,";
                }else {
                    thisQuery = key + "='" + val + "',";
                }

                settingQuery.append(thisQuery);
            }
            // 删掉最后一个逗号
            settingQuery.deleteCharAt(settingQuery.length() - 1);

            String sql = "update user set " + settingQuery.toString() + " where email='" + email + "'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect == 1){
                return true;
            }

        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    public boolean userSetHeadImage(String email, String imgName){
        try{
            String sql = "update user set head_image='"+imgName+"' where email='"+email+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect == 1){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 修改密码
    public boolean userChangePassword(String email, String password){
        try {
            String sql = "update user set password=password('" + password + "') where email='" + email + "'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect == 1){
                return true;
            }

        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 搜索用户
    public ResultSet searchUser(String keyword, int from, int to){
        try{
            String sql = "select id,nickname,area,sex,head_image,birthday,signature from user where email='" + keyword +  "' or nickname like '%" + keyword + "%' limit "+from+","+to;
            return querySql(sql);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    // 关注某用户id
    public boolean addFollowUser(String email, String userId){
        try {
            String sql = "insert into follow (from_id,to_id,time) select user.id,'" + userId + "','" + System.currentTimeMillis() + "' from user where user.email='" + email + "'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 取关
    public boolean removeFollow(String email, String userId){
        try {
            String sql = "delete from follow where to_id='"+userId+"' and from_id=(select id from user where email='"+email+"')";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 获取关注的人的列表
    public ResultSet getFollowList(String email, int from, int to){
        try {
            String sql = "select to_id,nickname,area,sex,head_image,time,birthday,signature from follow,user where from_id=(select id from user where email='" + email + "') and user.id=to_id order by time desc limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取粉丝列表
    public ResultSet getFansList(String email, int from, int to){
        try {
            String sql = "select from_id,nickname,area,sex,head_image,time,birthday,signature from follow,user where to_id=(select id from user where email='" + email + "') and user.id=from_id order by time desc limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取关注的人的列表
    public ResultSet getIdFollowList(String userId, int from, int to){
        try {
            String sql = "select to_id,nickname,area,sex,head_image,time,birthday,signature from follow,user where from_id='" + userId + "' and user.id=to_id order by time desc limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取粉丝列表
    public ResultSet getIdFansList(String userId, int from, int to){
        try {
            String sql = "select from_id,nickname,area,sex,head_image,time,birthday,signature from follow,user where to_id='" + userId + "' and user.id=from_id order by time desc limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 发送微博
    public boolean sendWeibo(String email, String content, String reBlog, String image){
        try {
            String sql = "";
            String extraColumn = "";
            String extraValue = "";

            if (reBlog != null && !reBlog.isEmpty()){
                extraColumn += ",reblog_id";
                extraValue += ",'"+reBlog+"'";
            }


            if (image != null && !image.isEmpty()){
                extraColumn += ",image";
                extraValue += ",'"+image+"'";
            }
//                sql = "insert into blog(user_id,content,time) select user.id,'"+content+"','"+System.currentTimeMillis()+"' from user where user.email='"+email+"'";
//            else
//                sql = "insert into blog(user_id,content,reblog_id,time) select user.id,'"+content+"','"+reBlog+"','"+System.currentTimeMillis()+"' from user where user.email='"+email+"'";
            sql = "insert into blog(user_id,content,time"+extraColumn+") select user.id,'"+content+"','"+System.currentTimeMillis()+"'"+extraValue+" from user where user.email='"+email+"'";

            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 判断某微博id是否存在
    public boolean isWeiboExist(String blogId){
        try {
            String sql = "select * from blog where id='"+blogId+"'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }

    // 列出首页微博
    public ResultSet listWeibo(String email, int from, int to){
        try {
//            String sql = "SELECT blog.id,blog.user_id,user.nickname,user.head_image,blog.content,blog.time," +
//                    "count(case when interact.type='like' then type end) as like_num," +
//                    "count(case when interact.type='comment' then type end) as comment_num," +
//                    "blog.reblog_id,b2.user_id as reblog_user,u2.nickname as reblog_nickname,u2.head_image as reblog_headimg,b2.content as reblog_content,b2.time as reblog_time " +
//                    "FROM ((blog left join interact on blog_id=blog.id) left join blog b2 on blog.reblog_id=b2.id) left join user u2 on b2.user_id=u2.id,follow,user " +
//                    "WHERE (blog.user_id=to_id and from_id=(select id from user where email='"+email+"') and user.id=to_id) or (blog.user_id=from_id and user.id=blog.user_id) " +
//                    "group by blog.id " +
//                    "order by blog.time DESC " +
//                    "limit "+from+","+to;
            String sql = "select blog.id,blog.user_id,user.nickname, user.head_image,blog.content,blog.time,blog.reblog_id,\n" +
                    "b2.user_id,u2.nickname,u2.head_image,b2.content,b2.time,blog.image,b2.image \n" +
                    "from ((blog left join blog b2 on blog.reblog_id=b2.id) left join user on blog.user_id=user.id) left join user u2 on b2.user_id=u2.id \n" +
                    "where blog.user_id in \n" +
                    "(select to_id from follow where from_id=(select id from user where email='"+email+"') union select id from user where email='"+email+"')\n" +
                    "order by blog.time desc \n" +
                    "limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 列出用户的个人首页的微博
    public ResultSet listUserWeibo(String email, int from, int to){
        try {
//            String sql = "select blog.id,blog.user_id,user.nickname,user.head_image,blog.content,blog.time, \n" +
//                    "count(case when interact.type='like' then type end) as like_num, \n" +
//                    "count(case when interact.type='comment' then type end) as comment_num,\n" +
//                    "blog.reblog_id,b2.user_id as reblog_user,u2.nickname as reblog_nickname,u2.head_image as reblog_headimg,b2.content as reblog_content,b2.time as reblog_time \n" +
//                    "FROM ((blog left join interact on blog_id=blog.id) left join blog b2 on blog.reblog_id=b2.id) left join user u2 on b2.user_id=u2.id,user \n" +
//                    "WHERE blog.user_id=(select id from user where email='"+email+"') and user.id=blog.user_id \n" +
//                    "group by blog.id \n" +
//                    "order by blog.time DESC " +
//                    "limit "+from+","+to;
            String sql = "select blog.id,blog.user_id,user.nickname, user.head_image,blog.content,blog.time,blog.reblog_id,b2.user_id,u2.nickname,u2.head_image,b2.content,b2.time,blog.image,b2.image \n" +
                    "from ((blog left join blog b2 on blog.reblog_id=b2.id) left join user on blog.user_id=user.id) left join user u2 on b2.user_id=u2.id \n" +
                    "where blog.user_id in \n" +
                    "(select id from user where email='"+email+"') \n" +
                    "order by blog.time desc \n" +
                    "limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 列出某用户id的个人首页的微博
    public ResultSet listUserIdWeibo(String userId, int from, int to){
        try {
//            String sql = "select blog.id,blog.user_id,user.nickname,user.head_image,blog.content,blog.time, \n" +
//                    "count(case when interact.type='like' then type end) as like_num, \n" +
//                    "count(case when interact.type='comment' then type end) as comment_num,\n" +
//                    "blog.reblog_id,b2.user_id as reblog_user,u2.nickname as reblog_nickname,u2.head_image as reblog_headimg,b2.content as reblog_content,b2.time as reblog_time \n" +
//                    "FROM ((blog left join interact on blog_id=blog.id) left join blog b2 on blog.reblog_id=b2.id) left join user u2 on b2.user_id=u2.id,user \n" +
//                    "WHERE blog.user_id='"+userId+"' and user.id=blog.user_id \n" +
//                    "group by blog.id \n" +
//                    "order by blog.time DESC " +
//                    "limit "+from+","+to;
            String sql = "select blog.id,blog.user_id,user.nickname, user.head_image,blog.content,blog.time,blog.reblog_id,b2.user_id,u2.nickname,u2.head_image,b2.content,b2.time,blog.image,b2.image \n" +
                    "from ((blog left join blog b2 on blog.reblog_id=b2.id) left join user on blog.user_id=user.id) left join user u2 on b2.user_id=u2.id \n" +
                    "where blog.user_id='"+userId+"' \n" +
                    "order by blog.time desc \n" +
                    "limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 点赞
    public boolean likeWeibo(String email, String blogId){
        try {
            String sql = "insert into interact(user_id,blog_id,type,time) select user.id,'"+blogId+"','like','"+System.currentTimeMillis()+"' from user where user.email='"+email+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 评论
    public boolean commentWeibo(String email, String blogId, String content){
        try {
            String sql = "insert into interact(user_id,blog_id,type,content,time) select user.id,'"+blogId+"','comment','"+content+"','"+System.currentTimeMillis()+"' from user where user.email='"+email+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 获取微博详情
    public ResultSet getWeiboDetail(String blogId){
        try {
            String sql = "select blog.id,blog.user_id,user.nickname,user.head_image,blog.content,blog.time,blog.reblog_id,\n" +
                    "b2.user_id as reblog_user_id,u2.nickname as reblog_nickname,u2.head_image as reblog_headimg,b2.content as reblog_content,b2.time as reblog_time,blog.image,b2.image\n" +
                    "FROM (blog left join blog b2 on blog.reblog_id=b2.id) left join user u2 on b2.user_id=u2.id,user\n" +
                    "where blog.id='"+blogId+"' and blog.user_id=user.id";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取微博转发数
    public int getWeiboReblogNum(String blogId){

        try {
            String sql = "select count(*) from blog where reblog_id='"+blogId+"'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret.getInt(1);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return 0;
    }

    // 用户对某条微博id是否点了赞
    public boolean isLikeWeibo(String email, String blogId){
        try {
            String sql = "select * from interact where user_id=(select id from user where email='"+email+"') and blog_id='"+blogId+"' and type='like'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }

    // 用户能否删除某微博id(该微博id是不是用户发的)
    public boolean canDeleteWeibo(String email, String blogId){
        try {
            String sql = "select * from blog where user_id=(select id from user where email='"+email+"') and id='"+blogId+"'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }

    // 列出某条微博id的评论
    public ResultSet listWeiboComment(String blogId, int from, int to){
        try {
            String sql = "select interact.id,user_id,nickname,head_image,content,time from interact,user where blog_id='"+blogId+"' and type='comment' and user.id=user_id " +
                    "order by time desc limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 用户能否删除某评论id(该评论id是不是用户发的)
    public boolean canDeleteComment(String email, String commentId){
        try {
            String sql = "select * from interact where user_id=(select id from user where email='"+email+"') and id='"+commentId+"' and type='comment'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }

    // 取消赞
    public boolean unlikeWeibo(String email, String blogId){
        try {
            String sql = "delete from interact where blog_id='"+blogId+"' and user_id=(select id from user where email='"+email+"') and type='like'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 删除评论
    public boolean deleteComment(String commentId){
        try {
            String sql = "delete from interact where id='"+commentId+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 删除微博
    public boolean deleteWeibo(String blogId){
        try {
//            String sql = "update blog set deleted='1' where id='"+blogId+"'";
            String sql = "delete from blog where id='"+blogId+"'";
            int rowEffect = conn.prepareStatement(sql).executeUpdate();
            if (rowEffect != 0){
                sql = "delete from interact where blog_id='"+blogId+"'";
                rowEffect = conn.prepareStatement(sql).executeUpdate();
                return rowEffect != 0;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 检查用户名是否存在
    public boolean isUsernameExist(String name){
        try {
            String sql = "select * from user where nickname='"+name+"'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return true;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return false;
    }

    // 检查用户名是否存在

    // 检查用户名是否存在
    // getUserInfo

    // 点赞数
    public String weiboLikeNum(String blogId){
        try{
            String sql = "select count(*) from interact where blog_id='"+blogId+"' and type='like'";
            ResultSet ret = querySql(sql);
            if (ret.next()){
                return ret.getString(1);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }

    // 热门微博
    public ResultSet hotWeibo(int from, int to){
        try {
            String sql = "select blog.id,blog.user_id,user.nickname, user.head_image,blog.content,blog.time,blog.reblog_id,b2.user_id,u2.nickname,u2.head_image,b2.content,b2.time,blog.image,b2.image \n" +
                    "from (((interact left join blog on blog.id=interact.blog_id) left join blog b2 on blog.reblog_id=b2.id) left join user on blog.user_id=user.id) left join user u2 on b2.user_id=u2.id \n" +
                    "group by blog_id \n" +
                    "order by count(blog_id) desc\n" +
                    "limit "+from+","+to;
            return querySql(sql);

        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 获取所有消息
    public ResultSet getAllMsg(String email, int from, int to){
        try{
            String sql = "select from,to,content,type,ref,time,read " +
                            "from msg where to=(select id from user where email='"+email+"')" +
                            "order by time desc limit "+from+","+to;
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }

    // 消息设置已读
    public boolean setReadMsg(String msgid){
        try {
            String sql = "update msg set read='1' where id='"+msgid+"'";
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 所有消息标位已读
    public boolean setReadAllMsg(String email){
        try {
            String sql = "update msg set read='1' where to=(select id from user where email='"+email+"')";

        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    // 发送消息
    public boolean sendMsg(String email, String content, int type, String ref){
        try {
            String sql = "insert into msg(from,to,content,type,ref,time) " +
                            "select user.id,'"+ref+"','"+content+"','"+type+"','"+ref+"','"+System.currentTimeMillis()+"' " +
                            "from user where user.email='"+email+"'";
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }


    // 发送点赞消息 - 1
    public boolean sendLikeMsg(String email, String blogId, String content){
        return sendMsg(email, "赞了你的微博", 1, blogId);
    }

    // 发送转发消息 - 2
    public boolean sendReblogMsg(String email, String blogId, String content){
        return sendMsg(email, content, 2, blogId);
    }

    // 发送评论消息 - 3
    public boolean sendCommentMsg(String email, String blogId, String content){
        return sendMsg(email, content, 3, blogId);
    }
    // 评论回复消息 - 4 预留
    public boolean sendReCommentMsg(String email, String blogId, String content){
        return sendMsg(email, content, 4, blogId);
    }

    // @消息 - 5
    public boolean sendAtMsg(String email, String to, String blogId, String content){
        return sendMsg(email, content, 5, blogId);
    }

}
